package com.nut.course;

import com.nut.course.entity.Demo;
import com.nut.course.entity.VisitsV1;
import com.nut.course.mapper.HitsV1Mapper;
import com.nut.course.mapper.VisitsV1Mapper;
import com.nut.course.service.DemoService;
import com.nut.course.service.impl.DemoServiceImpl;
import com.nut.course.util.SpringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.util.List;

@Slf4j
@EnableTransactionManagement
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
public class CourseApplication {

    public static void main(String[] args) {

        ConfigurableApplicationContext context = SpringApplication.run(CourseApplication.class, args);

        log.info("ActiveProfile=" + SpringUtil.getActiveProfile());
        Environment environment = context.getBean(Environment.class);
        log.info("http://localhost:" + environment.getProperty("local.server.port"));

//        HitsV1Mapper mapper = context.getBean(HitsV1Mapper.class);
//
//        List<String> list = mapper.selectDemo();
//        for (String s : list) {
//            System.out.println(s);
//        }

//        VisitsV1Mapper mapper = context.getBean(VisitsV1Mapper.class);
//
//        List<VisitsV1> list = mapper.selectDemo();
//        for (VisitsV1 s : list) {
//            System.out.println(s.getUrl());
//            System.out.println(s.getAvgDuration());
//        }


//        DemoService demoService = context.getBean(DemoService.class);
//
////        DemoService demoService = (DemoService) context.getBean("demoService", DemoServiceImpl.class);
//        Demo demo = new Demo();
//        demo.setName("dd");
//        demo.setDeptCode("df");
//        demo.setImg("f");
//        demo.setStatus(1);
//
//        demoService.add(demo);
        System.out.println("ff");

    }

//TODO 需要一个接口可以看所有机构发布的状态为正常的课程，是学校那端用，让教师看到所有机构的课程，然后进行采购
//TODO 学校查看课程详情，是用那个接口
//TODO 学校需要一个单接口，机构可以查看已经下单并审批完成的订单


    //TODO 机构看下的订单
    //TODO 学校看下的订单
    //TODO 区分学校

}
